$(function(){
	$('.order-item').click(function(e) {
        $(this).addClass('cur').siblings().removeClass('cur');
    });
	
	/* 02-21 价格筛选 start*/
	var list_pa=true;
	$('.order-item3').click(function(e) {
        if(list_pa==true){
			$(this).children().css('background-position','-176px 0');	
			list_pa=false;
		}else{
			$(this).children().css('background-position','-196px 0');	
			list_pa=true;	
		}
    });
	$('.order-item:not(.order-item3)').click(function(e) {
        $('.order-item3 em').css('background-position','-158px 0');	
		list_pa=true;
    });
	/* 02-21 价格筛选 end */
	
	$('.goods-sort-con .sort-first').click(function(e){
		
		var temp = $(this).children('em').attr('class').split(' ');
		console.log(temp[1]);
		if (temp[1] == 'sort-arr-down') {
			$(this).siblings('.goods-sort-second').hide();
			$('.goods-sort-con .v-icon').removeClass('sort-arr-down').addClass('sort-arr-right');
		}else{
			$('.goods-sort-con .goods-sort-second').hide();
			$('.goods-sort-con .v-icon').removeClass('sort-arr-down').addClass('sort-arr-right');
			$(this).children('.v-icon').removeClass('sort-arr-right').addClass('sort-arr-down');
			$(this).siblings('.goods-sort-second').show();
		}
	});
	
	$('.goods-sort-second span').click(function(){
		$(this).siblings('span').removeClass('cur');
		$(this).addClass('cur');
	});

	$('.filter-price-txt1').keyup(function(){
		var firstPrice = $(this).val();
		var z= /^[0-9]*$/;
		if(z.test(firstPrice)){
		   $('.filter-price-txt-confirm').show();
		}
	});

	$('.filter-con .filter-item a').click(function(e){
		$('.selected-con').show();
		$(this).parents('.filter-item').hide();
		$('.selected-con .selected').append('<div class="selected-item">'+$(this).html()+'<em class="v-icon selected-del"></em></div>');
	});
	$('body').on('click','.selected-del',function(){
		var item = $(this).parents('.selected-item').children('span').attr('class'),
		temp = item.split(' ');
		console.log(temp[0]);
		$(this).parents('.selected-item').remove();
		$('.'+temp[0]).parents('.filter-item').show();
		var selectedDelLen = $('.selected-del').length;
		if (selectedDelLen === 0) {
			$('.selected-con').hide();
		}
	});
	$('body').on('click','.selected-empty',function(){
		$('.selected-del').each(function(){
			$(this).click();
		});
	});
	$('.filter-brand-ul li').not('.filter-more').each(function(){
		$(this).children('.list-brand-info').css({left:(-($(this).index()%7)*130-1)+'px'});
	});
	$('.filter-more').hide();
	if ($('.filter-brand-ul li').not('.filter-more').length > 13 && $('.filter-brand-ul li').not('.filter-more').length < 28) {
		
		alert(2)
		$($('.filter-brand-ul li').not('.filter-more').get(12)).after($('.down-cont'));
		$('.down-cont').show();
		$('.filter-brand-ul li').not('.filter-more').each(function(){
			if ($(this).index()>12) {
				$(this).hide();
			}
		});

		$('.down-cont').click(function(){
			$(this).hide();
			$('.filter-brand-ul').append($('.up-cont'));
			$('.up-cont').show();
			$('.filter-brand-ul li').not('.filter-more').show();
		});
		$('.up-cont').click(function(){
			$(this).hide();
			$($('.filter-brand-ul li').not('.filter-more').get(12)).after($('.down-cont'));
			$('.down-cont').show();
			$('.filter-brand-ul li').not('.filter-more').each(function(){
				if ($(this).index()>12) {
					$(this).hide();
				}
			});
		});
		
	}else if( $('.filter-brand-ul li').not('.filter-more').length > 27){
		
		// 待处理
		$($('.filter-brand-ul li').not('.filter-more').get(12)).after($('.down-cont'));
		$('.down-cont').show();
		$('.filter-brand-ul li').not('.filter-more').each(function(){
			if ($(this).index()>12) {
				$(this).hide();
			}
		});

		$('.down-cont').click(function(){
			console.log(1)
			$(this).hide();
			$($('.filter-brand-ul li').not('.filter-more').get(26)).after($('.up-cont'));
			$('.up-cont').show();
			$('.filter-brand-ul li').not('.filter-more').show();
			$('.filter-brand-ul li').not('.filter-more').each(function(){
				if ($(this).index()>27) {
					$(this).hide();
				}
			});
		});
		$('.up-cont').click(function(){
			$(this).hide();
			$($('.filter-brand-ul li').not('.filter-more').get(12)).after($('.down-cont'));
			$('.down-cont').show();
			$('.filter-brand-ul li').not('.filter-more').each(function(){
				if ($(this).index()>12) {
					$(this).hide();
				}
			});
		});
		
	};
	
});